package com.ruoyi.iot.domain.dto;

import com.ruoyi.iot.domain.entity.DeviceTemperatureWindow;
import io.swagger.v3.oas.annotations.media.Schema;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import lombok.Data;
import org.springframework.beans.BeanUtils;

/**
 * 设备温度窗口导出DTO
 */
@Data
public class DeviceTemperatureWindowExportDTO {

    @Schema(description = "设备编号")
    private String deviceId;

    @Schema(description = "设备名称")
    private String deviceName;

    @Schema(description = "窗口开始时间")
    private LocalDateTime windowStart;

    @Schema(description = "窗口结束时间")
    private LocalDateTime windowEnd;

    @Schema(description = "聚合粒度(分钟)")
    private Integer granularityMinutes;

    @Schema(description = "样本数量")
    private Integer sampleCount;


    /** 定子A相温度1平均值 */
    @Schema(description = "定子A相温度1平均值")
    private BigDecimal avgAstatortemp1;

    /** 定子B相温度1平均值 */
    @Schema(description = "定子B相温度1平均值")
    private BigDecimal avgBstatortemp1;

    /** 定子C相温度1平均值 */
    @Schema(description = "定子C相温度1平均值")
    private BigDecimal avgCstatortemp1;

    /** 定子A相温度2平均值 */
    @Schema(description = "定子A相温度2平均值")
    private BigDecimal avgAstatortemp2;

    /** 定子B相温度2平均值 */
    @Schema(description = "定子B相温度2平均值")
    private BigDecimal avgBstatortemp2;

    /** 定子C相温度2平均值 */
    @Schema(description = "定子C相温度2平均值")
    private BigDecimal avgCstatortemp2;

    /** 轴伸端温度平均值 */
    @Schema(description = "轴伸端温度平均值")
    private BigDecimal avgShaftendtemp;

    /** 非轴伸端温度平均值 */
    @Schema(description = "非轴伸端温度平均值")
    private BigDecimal avgNonshaftendtemp;

    /** 水泵轴承温度平均值 */
    @Schema(description = "水泵轴承温度平均值")
    private BigDecimal avgWaterpumpbearingtemp;

    /** 定子A相温度1最大值 */
    @Schema(description = "定子A相温度1最大值")
    private BigDecimal maxAstatortemp1;

    /** 定子B相温度1最大值 */
    @Schema(description = "定子B相温度1最大值")
    private BigDecimal maxBstatortemp1;

    /** 定子C相温度1最大值 */
    @Schema(description = "定子C相温度1最大值")
    private BigDecimal maxCstatortemp1;

    /** 定子A相温度2最大值 */
    @Schema(description = "定子A相温度2最大值")
    private BigDecimal maxAstatortemp2;

    /** 定子B相温度2最大值 */
    @Schema(description = "定子B相温度2最大值")
    private BigDecimal maxBstatortemp2;

    /** 定子C相温度2最大值 */
    @Schema(description = "定子C相温度2最大值")
    private BigDecimal maxCstatortemp2;

    /** 轴伸端温度最大值 */
    @Schema(description = "轴伸端温度最大值")
    private BigDecimal maxShaftendtemp;

    /** 非轴伸端温度最大值 */
    @Schema(description = "非轴伸端温度最大值")
    private BigDecimal maxNonshaftendtemp;


    /**
     * 将实体对象转换为导出DTO
     *
     * @param source 设备温度窗口实体
     * @param deviceName 设备名称
     * @return 导出DTO实例
     */
    public static DeviceTemperatureWindowExportDTO from(DeviceTemperatureWindow source, String deviceName) {
        DeviceTemperatureWindowExportDTO target = new DeviceTemperatureWindowExportDTO();
        BeanUtils.copyProperties(source, target);
        target.setDeviceName(deviceName);
        return target;
    }
}
